<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../../js/vue.js"></script>
</head>

<body>
    <div id="app">
        <div v-fontweight='900'>{{msg}}</div>
        <div v-fontsize='50'>{{msg}}</div>
        <div v-color="'pink'">{{msg}}</div> 自定义颜色
    </div>
    <script>
        Vue.directive(
            "color", {
            bind: function (el, binding) {
                el.style.color = "red" //所有
                el.style.color = binding.value //自定义颜色 
                console.log(binding.value); //pink
                console.log(binding.expression) //'pink'
            }
        })
        new Vue({
            el: "#app",
            data: {
                msg: "嘻嘻嘻嘻嘻"
            },
            directives: {
                'fontweight': {
                    bind: function (el, binding) {
                        el.style.fontWeight = binding.value
                    }
                },
                'fontsize':{
                    bind:function (el,binding){
                        el.style.fontSize=parseInt(binding.value)+"px"
                    }
                },
                'background':{
                    bind:function(el,binding){
                        el.style.background=binding.value
                    }
                }

            }
        })

        
    </script>

</body>

</html>